{include file="public/header"/}
<body>
 <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="{:url('admin/index/main')}">首页</a>
        <a href="{:url('index')}">用户管理</a>
        <a>
          <cite>编辑</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.5em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:40px">ဂ</i></a>
</div>
<div class="x-body">
<blockquote class="layui-elem-quote">
   <button class="layui-btn" style="background:#5FB878;" onclick="javascript :history.back(-1);"><i class="layui-icon" style="color: #fff">&#xe65c;</i>返回</button>
   <button class="layui-btn" style="background:#00BFFF;"><i class="layui-icon" style="color: #fff">&#xe642;</i>编辑</button>
</blockquote>
    <div class="x-body layui-anim layui-anim-up">
        <form class="layui-form" method="post">
            <input type="hidden" name="uid" value="{:input('param.uid')}">
            <div class="layui-form-item">
              <label class="layui-form-label">密码</label>
              <div class="layui-input-inline">
                <input type="password" name="password" autocomplete="off" placeholder="请输入用户密码" class="layui-input" lay-verify="password" id="password">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">确认码</label>
              <div class="layui-input-inline">
                <input type="password" name="passwords" autocomplete="off" placeholder="请确认密码" class="layui-input" lay-verify="passwords" id="passwords">
              </div>
            </div>
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button type="submit" class="layui-btn btns" lay-submit="" lay-filter="edit">编辑</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
              </div>
            </div>
        </form>
    </div>   
</div> 
<script>
var url = '{:url("editpass")}';
layui.use(['form','layer'], function(){
    var form = layui.form
    ,layer = layui.layer
    ,$ = layui.jquery;

    //自定义验证规则
    form.verify({
      passwords: function(value){
          if($('#password').val()!=$('#passwords').val()){
              return '两次密码不一致';
          }
      }
    });

    //监听提交
    form.on('submit(edit)', function(data){
      $.post(url,data.field,function(res){
          if(res.code == 1){
            layer.alert(res.msg, {icon: 6},function () {
                window.location.href = res.url;
            });
          }else{
            layer.alert(res.msg, {icon: 5}); 
          }
      },'json')
        return false;
    }); 
});
</script>
</body>
</html>